package cn.wx.controller;

import cn.wx.domain.User;
import cn.wx.sentine.SentineBlock;
import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import com.sun.deploy.security.BlockedException;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
public class UserController {

    @GetMapping("/get/{id}")
    @SentinelResource(value = "getUser",blockHandler = "degradationMethod",blockHandlerClass = SentineBlock.class)
    public User getUser(@PathVariable Long id){
        return new User(id,"王天霸","齐天大圣");
    }

   /* public User degradationMethod(@PathVariable Long id, BlockException e){
        e.printStackTrace();
        return new User(-1L,"熔断了","不要再来了，求求了");
    }*/


}
